package com.xyb.controller;

import com.xyb.entity.CourseDoc;
import com.xyb.service.CourseDocService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("course-doc")
public class CourseDocController {
    @Resource
    private CourseDocService courseDocService;

    @PostMapping("{courseDetailId}")
    public String insertCourseDocByCourseDetailId(@PathVariable("courseDetailId") Long courseDetailId, @RequestBody List<CourseDoc> courseDocList) {
        return courseDocService.insertCourseDocByCourseDetailId(courseDetailId,courseDocList);
    }

    @GetMapping("{courseDetailId}")
    public List<CourseDoc> selectCourseDocByCourseDetailId(@PathVariable("courseDetailId") Long courseDetailId) {
        return courseDocService.selectCourseDocByCourseDetailId(courseDetailId);
    }

    @DeleteMapping("{courseDocId}")
    public String deleteCourseDocByCourseDocId(@PathVariable("courseDocId") Long courseDocId) {
        return courseDocService.deleteCourseDocByCourseDocId(courseDocId);
    }

    @PutMapping("order")
    public String updateCourseDocShowOrder(@RequestBody Long[] courseDocIds){
        return courseDocService.updateCourseDocShowOrder(courseDocIds);
    }
}
